<template>
    <el-button v-bind="$attrs" :disabled="disabled" @click='onclick'>
<slot></slot>
    </el-button>
</template>


<script lang="ts" setup>
import { ref, watch, computed, onMounted, PropType } from 'vue'
import { ElMessage } from 'element-plus'
import { ActionState } from '@/common/AuthState'

const props = defineProps({
  useAuth: {type:Boolean, required:true, default: true},
  useLock: {type:Boolean, required:true, default:true},
  authTag: {type:Number, required:true, default: 0xFFFF},
  lockState: {type:Number, required:true, default: 0},
  masterLockState: {type:Number, required:true, default: 0},
});

const actionState = computed(()=>{
    return new ActionState(props.useAuth, props.useLock, props.authTag, props.lockState, props.masterLockState);
});

const disabled=computed(()=>{
    return actionState.value.readonly();
});

const emit = defineEmits(["click"]);

const onclick=()=>{
    if(actionState.value.readonly()){
        return;
    }
    emit("click");
}

</script>